<html>
 <head>
    <title>[var.TITLE]</title>
    <link href="[var.ROOT_CSS_DIR]/main.css" rel="STYLESHEET" type="text/css" charset="iso-8859-1" hreflang="en-us">
    <link href="[var.ROOT_CSS_DIR]/facet/style.css" rel="STYLESHEET" type="text/css" charset="iso-8859-1" hreflang="en-us">
    <script type="text/javascript" src="[var.ROOT_DIR]js/common.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/doiMenuDOM.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/functions.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmenu.php"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmenu.cfg"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsformgrid.php?session=[var.SessionVar]"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmasks.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsverify.php?session=[var.SessionVar]"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsinit.php?session=[var.SessionVar]"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jquery.min.js"></script>
 </head>
 <body bgcolor="FFFFFF" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
    <table border="0" cellspacing="0" cellpadding="0" width="100%" align="[var.POSITION]">
        <tr>
            <td>[tbs_include.onshow;file=[var.HTMLHeader];getob;]</td>
        </tr>
        <tr>
            <td>
            <table border="0" cellspacing="0" cellpadding="0" width="100%">
                <tr>
                    <td class="mainmenu2"><img src="images/spacer.gif" height="1" width="1"></td>
                </tr>
                <tr>
                    <td background="[var.ROOT_IMG_DIR]/back-menu.gif">
                    <table border="0" cellspacing="0" cellpadding="0" width="100%">
                        <tr>
                            <td>
                            <script language="JavaScript" type="text/JavaScript">menu.Build();</script>
                          </td>
                          <td class="head-login">Login as [var.USERPROFILE_NAME]</td>
                        </tr>
                      </table>
                    </td>
                </tr>
                <tr>
                    <td class="mainmenu2"><img src="images/spacer.gif" height="1" width="1"></td>
                </tr>
            </table>
            </td>
        </tr>
        <tr height="100%">
            <td>
            <table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
                <tr valign="top">
                    <td width="100%">
                        <table border="0" cellspacing="0" cellpadding="0" width="100%">
                            <tr>
                                <td class="head-path"></td>
                                <td class="corner-date">[var.CORNER_DATE]</td>
                            </tr>
                        </table>
                        <table border="0" cellspacing="0" cellpadding="5" width="100%">
                            <tr>
                                <td class="FacetHeaderContent" >.:[var.SubHeaderTitle]:.</td>
                            </tr>
                        </table>

                        <table border="0" cellspacing="0" cellpadding="5" width="100%">
                            <tr>
                                <td class="contentTitleOperational">
                                Menu
                                </td>
                            </tr>
                            <tr>
                                <td class="contentOperational">
                                <table cellspacing="2" cellpadding="0">
                                 <tr>
                                   <td>
                                    <input type="button" name="Action" value="<<Back" class="button" onClick="self.location.replace('[sys.script_name]')">
                                   </td>
                                   <td>[tbs_check;block=td;if [var.USER_CANPRINT]=1]
                                    <input type="button" name="Action" value="Print Voucher" class="button" onClick="OpenPDF('[sys.script_name]?PageMode=PDF&[var.PRIMARY_KEY]=[var.PRIMARY_VALUE]&office=[var.KTRASL]')">
                                   </td>
                                   <td>[tbs_check;block=tr;if [var.USER_CANINSERT]=1][tbs_check;block=td;if [var.FormMode]='Edit']
                                    <input type="button" name="Action" value="Add New" class="button" onClick="self.location.replace('[sys.script_name]?PageMode=Form')">
                                   </td>
                                   <td>
                                    <input type="button" name="Action" value="Done" class="button" onClick="self.location.replace('[var.SERVER_URL]')">
                                   </td>
                                 </tr>
                                </table>
                                </td>
                            </tr>
                            <tr>
                                <td class="contentOperational">
                        <!-- FORM SECTION -->
                        <table border="0" cellspacing="0" cellpadding="0" width="100%">
                        <form method="post" action="[var.FormAction]" name="[var.HTMLFormName]" ONSUBMIT="if (this.submitted) return true; else return false;">
                              <tr>
                                <td class="fieldCaption" align="right">ID No.</td>
                                <td class="fieldCaption" width="2">:</td>
                                <td class="fieldCaption">
                                <input type="text" name="[headbln.nobkt]" value="[tbs_check;if [var.FormMode]=Edit;then [headblv.nobkt] ;else 'AUTO NUMBERED BY SYSTEM']" maxlength="255" size="25" class="input" onkeyup="this.value=this.value.toUpperCase()" class="input" readonly>
                  <input type="hidden" name="app1" value="[headblv.app1]">
                  <input type="hidden" name="nmapp1" value="[headblv.nmapp1]">
                                </td>

                                <td class="fieldCaption" align="right">Payment To</td>
                                <td class="fieldCaption" width="2">:</td>
                                <td class="fieldCaption">
                                <select name="receivedList" class="input" onchange="GetReceived(this.value);">
                                    <option value="" selected>Select Value</option>
                                    <option value="2">Staff</option>
                                </select>

                                <input type="text" name="[headbln.debnam]" value="[headblv.debnam]" maxlength="255" size="25" class="input" onclick="GetReceived(this.value);" readonly>
                                <input type="hidden" name="[headbln.debtur]" value="[headblv.debtur]" maxlength="255" size="25">
                                </td>
                              </tr>
                              <tr>
                                <td class="fieldCaption" align="right">Transaction Date</td>
                                <td class="fieldCaption" width="2">:</td>
                                <td class="fieldCaption">
                                <input type="text" name="[headbln.tglbkt]" value="[tbs_check;if [var.FormMode]=Edit;then [headblv.tglbkt;frm='dd/mm/yyyy']; else [sys.now;frm='dd/mm/yyyy']]" maxlength="255" size="10" class="input">
                                <a href="javascript:void(0)" onclick="gfPop.fPopCalendar([var.HTMLFormName].[headbln.tglbkt]);return false;" hidefocus>
                                    <img name="popcal" align="absMiddle" src="[var.ROOT_DIR]js/Calendar/pop/calbtn.gif" width="34" height="22" border="0" alt=""></a>
                                </td>

                                <td class="fieldCaption" align="right">Order No.</td>
                                <td class="fieldCaption"></td>
                                <td class="fieldCaption">
                                <input type="text" name="[headbln.noorder]" value="[headblv.noorder]" maxlength="255" size="25" class="input">
                                </td>
                              </tr>
                              <tr>
                                <td class="fieldCaption" align="right">Currency</td>
                                <td class="fieldCaption" width="2">:</td>
                                <td class="fieldCaption">
                                <select name="[headbln.curr]" class="input" onchange="GetRate()">
                                  <option value="">-</option>
                                  <option value="[currformblk.tusymbol]">[currformblk.tusymbol;block=option]</option>
                                  <option>[headblv.curr;selected;noerr]</option>
                                </select>
                                </td>

                                <td class="fieldCaption" align="right"><!--Job Order Ref--></td>
                                <td class="fieldCaption"><!--:--></td>
                                <td class="fieldCaption">

                                <!--
                                    <select name="joList" id="input" [tbs_check;if [var.FormMode]=Edit;then 'disabled';else ''] onchange="GetJo();">
                                            <option value="" selected>Select Value</option>
                                            <option value="1">Job Order</option>
                                    </select>

                                <input type="hidden" id="jo_ido" name="jo_ido" value="[headblv.jo_id;noerr]" class="input" maxlength="50"  size="10" [tbs_check;if [var.FormMode]=Edit;then 'disabled';else '']>
                                <input type="text" id="jo_code" name="jo_code" value="[headblv.jo_code;noerr]" maxlength="255" size="25" class="input" readonly>
                                -->

                                </td>


                              </tr>
                              <tr>
                                <td class="fieldCaption" align="right">Currency Rate</td>
                                <td class="fieldCaption" width="2">:</td>
                                <td class="fieldCaption">
                                <input type="text" name="[headbln.rate]" value="[headblv.rate;frm='0,000.00']" maxlength="255" size="10" class="inputNumber" readonly>
                                </td>

                                <td class="fieldCaption" align="right"></td>
                                <td class="fieldCaption"></td>
                                <td class="fieldCaption">
                                </td>
                              </tr>
                              <tr>
                               <td class="fieldCaption"></td>
                               <td class="fieldCaption"></td>
                               <td align="right" class="fieldCaption"></td>
                              </tr>
                         </table>
                         <!-- FORM SECTION -->
                                </td>
                            </tr>
                        </table>
                        <hr size="1" color="DFDFDF">
                        <div id="spanHeader" style="height: 25px; vertical-align: top; overflow: noscroll;">
                        <table border="0" width="100%" cellpadding="3" cellspacing="1" class="FacetFormTABLEOperational" align="left">
                        <input type=hidden name="NewData" value="[var.NewDataStart]">
                            <tr>
                                <td nowrap class="FacetColumnTDOperational" align="center" width="50">X</td>
                                <td nowrap class="FacetColumnTDOperational" align="center" width="50">No.</td>
                                <td nowrap class="FacetColumnTDOperational" align="center" width="550">Description</td>
                                <td nowrap class="FacetColumnTDOperational" align="center" width="200">COA</td>
                                <td nowrap class="FacetColumnTDOperational" align="center">AMOUNT</td>
                            </tr>
                        </table>
                        </div>
                        <div id="spanDetail" style="height: 200px; vertical-align: top; overflow: auto;">
                        <table border="0" width="100%" cellpadding="3" cellspacing="1" class="FacetFormTABLEOperational" align="left">

                            <tr id="[blg.#]" style="display:[blg._display;noerr]">
                                <td nowrap class="FacetDataTDOperational" align="center" width="50" align="center">
                                    <input type="checkbox" name="txtCheck[blg.#]" value="[blg.adv_id;noerr]" class="inputRadio">
                                    <input type="hidden" name="adv_id[blg.#]" value="[blg.adv_id;noerr]" maxlength="255" size="25">
                                    <input type="hidden" name="urut[blg.#]" value="[blg.#;noerr]" maxlength="255" size="15" class="input">
                                </td>
                                <td nowrap class="FacetDataTDOperational" align="center" width="50" align="center">[blg.#].</td>
                                <td nowrap class="FacetDataTDOperational" width="550" align="center">
                                   <input type="text" name="uraian[blg.#]" value="[blg.uraian;noerr;block=tr]" maxlength="255" size="55" class="gridBox" id="input" onkeyup="this.value=this.value.toUpperCase()">
                                </td>
                                <td nowrap class="FacetDataTDOperational" width="200" align="center">
                                   <input type="text" name="skada[blg.#]" value="[blg.skada;noerr;block=tr]" size="15"  id="input"  onClick="this.blur();openSkada([blg.#]);">
                                   <input type="hidden" name="kdact[blg.#]">
                                </td>
                                <td nowrap class="FacetDataTDOperational" align="center">
                                   <input type="text" name="jumlah[blg.#]" value="[blg.jumlah;noerr;frm='0,000.00']" maxlength="255" size="10" onkeyup="this.form.total_trans.value = SumTotal ('jumlah')" class="inputNumber">
                                </td>
                            </tr>
                        </table>
                        </div>

                        <div id="spanButton" style="height: 35px; vertical-align: top; overflow-y: noscroll;">
                        <table border="0" width="100%" cellpadding="3" cellspacing="1" class="FacetFormTABLEOperational" align="left">
                            <tr>
                                <td align="right" class="FacetDataTDOperational">Total Amount:  <input type="text" name="total_trans" value="" maxlength="255" size="15" class="inputNumber"></td>
                            </tr>
                            <tr>
                                <td align="right" class="FacetColumnTDOperational">
                                <table border="0" cellspacing="2" cellpadding="0">
                                    <tr>
                                        <td><!--[tbs_check;block=td;if [var.USER_CANINSERT]=1]--> [tbs_check;block=td;if [var.FormMode]!='Edit']
                                            <input name="FormAction" type="submit" value="Next Line" class="button" onclick="return (AddFormGrid(this,'[var.HTMLFormName].uraian'))">
                                        </td>
                                        <td><!--[tbs_check;block=td;if [var.USER_CANUPDATE]=1]--> [tbs_check;block=td;if [var.FormMode]!='Edit']
                                            <input name="FormAction" type="button" value="Delete Line" class="button" onClick="DeleteLines()">
                                        </td>
                                        <td><!--[tbs_check;block=td;if [var.USER_CANINSERT]=1][tbs_check;block=td;if [var.USER_CANUPDATE]=1]-->[tbs_check;block=td;if [var.FormMode]!='Edit']
                                            <input name="FormAction" type="submit" value="Save" class="button" ONCLICK="return checkVerification(this.form);">
                                        </td>
                                                                                
                                        <td>[tbs_check;block=td;if [var.FormMode]=Edit]
                                            <input name="FormAction" type="submit" value="Cancel BS" class="button" onClick="this.form.submitted = true; return true;">
                                        </td>
                                    </tr>
                                </table>
                                </td>
                                </td>
                            </tr>
                            </form>
                        </table>
                        </div>
                    </td>
                </tr>
            </table>
            </td>
        </tr>
        <tr>
            <td>
            <br>
            <table border="0" cellspacing="0" cellpadding="0" width="100%">
                <tr>
                    <td class="footer1"><img src="images/spacer.gif" height="1" width="1"></td>
                </tr>
                <!--tr>
                    <td class="footer2">Prototype Test - Web Application</td>
                </tr-->
            </table>
            </td>
        </tr>
    </table>
 </body>
 <iframe width="174" height="189" name="gToday:normal:agenda.js" id="gToday:normal:agenda.js" src="[var.ROOT_DIR]js/Calendar/pop/ipopeng.htm" scrolling="no" frameborder="0" style="LEFT: -500px; POSITION: absolute; TOP: 0px; VISIBILITY: visible; Z-INDEX: 999"></iframe>
 <script>

 function GetJo() {
            //newwin = window.open("ais_transaction_jolist.php?FormName=[var.HTMLFormName]&need_another_var="+need_another_var,"toolcalc","height=400,width=640,noscroll,resizable");
            newwin = window.open("ais_transaction_jolist.php?FormName=[var.HTMLFormName]&SendToBack=1", "toolcalc","height=400,width=640,noscroll,resizable");
 }

 [var.InitFunction]

 document.[var.HTMLFormName].total_trans.value = SumTotal("jumlah");

 function GetReceived2(val) {
     switch (val){
        case "1":
            newwin = window.open("ais_transaction_custlist.php?FormName=[var.HTMLFormName]","toolcalc","height=400,width=640,noscroll,resizable");
            break;
        case "2":
            newwin = window.open("ais_transaction_stafflist.php?FormName=[var.HTMLFormName]&need_another_var=advance_payment_to","toolcalc","height=400,width=640,noscroll,resizable");
            break;
        case "3":
            newwin = window.open("ais_transaction_vendorlist.php?FormName=[var.HTMLFormName]","toolcalc","height=400,width=640,noscroll,resizable");
            break;
     }
 }

 function GetReceived(val) {
            newwin = window.open("ais_transaction_stafflist.php?FormName=[var.HTMLFormName]&need_another_var=advance_payment_to","toolcalc","height=400,width=640,noscroll,resizable");
 }

function OpenCalc(formname, desc, total, act, qty, tarif) {
    newwin = window.open("ais_transaction_calc.php?PageMode=Form&desc="+desc+"&total="+total+"&act="+act+"&qty="+qty+"&tarif="+tarif+"&formname="+formname,"toolcalc","height=10,width=450,noscroll,resizable")
}

 function OpenPrincipal (number) {
    newwin = window.open("ais_transaction_receipt_entry.php?PageMode=Page2&FormName=[var.HTMLFormName]&Number="+number,"vessel","height=105,width=300,noscroll,noresizable");
 }

 function OpenPrint (number) {
    newwin = window.open("ais_transaction_adventry.php?PageMode=PrintPreview&nobkt="+number,"print","height=650,width=600,noscroll,noresizable");
 }

 function GetRate() {
     tgl_curr = document.[var.HTMLFormName].tglbkt.value;
     if (tgl_curr.length) LoadRPC ("iLoader", "[var.FileName]", "curr="+document.[var.HTMLFormName].curr.value+"&tglbkt="+tgl_curr);
 }

 function CheckPeriod () {
     var ledger = document.[var.HTMLFormName].tglbkt.value;
     var value = "open";

     var param = 'ledger='+ledger;
     $.ajax({ type: "post", url: "ais_transaction_check_period.php", data: param, dataType: "xml",
         success: function(xml){
            $('status', xml).each(function(i){
               value = $('periodstatus', this).text();
            });
        },
        async:   false,
     });

     if(value == "open"){
        return true;
     }else{
        alert('Invalid Date, Period Already Closed Or Not Yet Opened!');
        return false;
     }
 }

 function GetSkada() {
     skada1 = document.[var.HTMLFormName].thbl.value;
     if (skada1.length) LoadRPC ("iLoader", "[var.FileName]", "thbl="+document.[var.HTMLFormName].thbl.value);
 }

 function SumTotal (component) {
     oMask = new Mask('#,###.#0', 'number');
     var comp_str = "document.[var.HTMLFormName]."+component;

     var TotalComponent = [var.MaxGrid] + [var.NewDataStart] - 1;
     var sum_all = 0;
     var subtotal = 0;
     var js_str = "";

     for (x=1;x<=TotalComponent;x++) {
       js_str = "subtotal = "+comp_str+x+".value";
       eval (js_str);

       if (subtotal.length) subtotal = StrToNumber(subtotal);
       else subtotal = 0;

       sum_all = sum_all + parseFloat(subtotal);
     }
     return oMask.format(sum_all);
 }


 var reccount = 1;
 var last;

 function AddFormGrid (cname,firstelemen) {
    var lastname ="";

    if (VerifyGridProject(reccount)==false) {
        return false
    }

    $(".gridBox:visible").each(function(n) {
        n = n+1;
        reccount = n;
        lastname = this.name;
    });

    lastname = lastname.substring(6);

    lastname = parseInt(lastname)+1;

    //reccount = 5;
    reccount = parseInt(reccount)+1;

    //alert("reccount: " + reccount);

    if (reccount>=100) {
        cname.disabled = true;
    }

    var objrow = document.getElementById(lastname);
//alert(lastname);
    if (objrow.style.display == 'none') {
        objrow.style.display = '';
    }

    eval(firstelemen+''+lastname+'.focus()');

    return false;
}


function VerifyGridProject (x) {
    err_message = '';
    last_focus =0;
    if (err_message.length) {//alert(err_message);
    return false} else return true
}


function DeleteLines(){
    $("input[name^=txtCheck]").each(
      function(){
        if($(this).attr('checked')) {
            //alert($(this).val());
            var num = String($(this).attr('name')).replace('txtCheck','');
            //alert('num: ' + num);
            $('tr#'+num).remove();
        }
      }
    );
 }



function checkVerification(element)
{
    var checksum = 0;
    var errorMsg = "";

    var curr = eval("document.[var.HTMLFormName].curr.value");
    var debtur = eval("document.[var.HTMLFormName].debtur.value");
    var noorder = eval("document.[var.HTMLFormName].noorder.value");


    if(curr == "")
    {
        errorMsg+= "Cuurency should not empty\n";
    }

    if(debtur == "")
    {
        errorMsg+= "Customer should not empty\n";
    }

    if(noorder == "")
    {
        errorMsg+= "Order No should not empty\n";
    }




    $(".gridBox:visible").each(function(n) {
        lastname = this.name;
        lastname = lastname.substring(6);

        if(lastname!="")
        {
            lastname = parseInt(lastname);


            var uraian = eval("document.[var.HTMLFormName].uraian"+lastname+".value");
            var skada = eval("document.[var.HTMLFormName].skada"+lastname+".value");
            var jumlah = eval("document.[var.HTMLFormName].jumlah"+lastname+".value");


            if((uraian != "") && (skada != "") && (jumlah != ""))
            {
              checksum++;
            }
        }

    });

    if(checksum < 1)
    {
        errorMsg+= "Your grid is not complete\n";
    }

    if(errorMsg != "")
    {
        alert(errorMsg);
        return false;
    }

    else
    {
        element.submitted = true;
        return true;
    }


}



 function openSkada(idx) {
    tglbkt = document.[var.HTMLFormName].tglbkt.value;
        newwin = window.open("ais_transaction_coapicker.php?idx="+idx+"&FormName=[var.HTMLFormName]"+"&Field=skada"+idx+"&BMode=MEM"+"&period="+tglbkt+"&group=NOTAR","skadasearch","height=400,width=640,noscroll,noresizable");
 }



 </script>
</html>
